import Vue from 'vue'
import App from './App'
import store from './store'
import http from '@/utils/http/api.js' //全局API请求方法
import CHS from '@/utils/common/functions.js' //全局常用业务处理方法
import {router, RouterMount} from './router/router.js' //路由配置
import {goByName, goByPath, goBack} from '@/utils/common/common.js' //公用跳转方法

//引入全局功能组件
import ShowToast from '@/components/ch-toast/ch-showtotast.js' //全局信息提示
import ShowLoading from '@/components/ch-loading/ch-showLoading.js' //加载动画(JS扩展版)
const pageloading = () => import('@/components/ch-loading/ch-pageLoading.vue'); //加载动画(组件版)
const neterror = () => import('@/components/ch-neterror/ch-neterror.vue'); //网络异常提示
const LazyImage = () => import('@/components/ch-image/ch-image.vue'); //图片懒加载组件

//引入全局业务组件
const articlelist = () => import('@/components/ch-article/ch-articlelist'); //料列表
const fullvideo = () => import('@/components/full-video/full-video'); //播放视频
const emptycontent = () => import('@/components/ch-empty/ch-emptycontent'); //列表空内容
const appdown = () => import('@/components/ch-appdown/ch-appdown'); //APP下载引导
//设备型号
const platform=uni.getSystemInfoSync().platform
const isweixin=null
//判断客户端类型
let ua = navigator.userAgent.toLowerCase();
//是否在微信打开
if (ua.match(/micromessenger/i) == "micromessenger"){
	store.commit("IS_WEIXIN",true)
}else{
	store.commit("IS_WEIXIN",false)
}
//初始化Tabbar图标
CHS.updateTabbarIcon()
//初始化登录状态
store.commit('INIT_LOGIN')
//挂载全局组件
Vue.component('ArticleList', articlelist);
Vue.component('FullVideo', fullvideo);
Vue.component('EmptyContent', emptycontent);
Vue.component('AppDown', appdown);
Vue.component('NetError', neterror);
Vue.component('PageLoading', pageloading);
Vue.component('LazyImage', LazyImage);

//加载插件，挂载数据
Vue.prototype.$store = store
Vue.prototype.$http = http
Vue.prototype.$CHS = CHS
Vue.prototype.$goByName = goByName
Vue.prototype.$goByPath = goByPath
Vue.prototype.$goBack = goBack
Vue.prototype.$ShowToast = ShowToast
Vue.prototype.$ShowLoading = ShowLoading
Vue.prototype.platform=platform
Vue.use(router)
Vue.config.errorHandler = function (err, vm, info) {
	console.log(err,'err')
  const pattern = /Loading chunk (\d)+ failed/g;
  const isChunkLoadFailed = err.message.match(pattern);
  if (isChunkLoadFailed) {
    window.location.reload();
    // router.replace(targetPath);
  } else {
    console.log('no')
  }
}

//解决echarts手机端兼容问题
window.wx = {}

//其他Vue配置
Vue.config.productionTip = false
//Vue.config.ignoredElements.push('wx-open-launch-weapp')

App.mpType = 'app'

const app = new Vue({
    ...App
})

// #ifdef H5
	RouterMount(app,router,'#app')
// #endif

// #ifndef H5
	app.$mount(); //为了兼容小程序及app端必须这样写才有效果
// #endif